package com.khyr.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.khyr.Vo.ProviderVo;
import com.khyr.entity.StockProvider;
import com.khyr.service.ProviderService;
import com.khyr.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: ProviderController
 * @author: Zyl
 * @date: 2025/3/12 20:39
 * @Version: 1.0
 * @description:
 */
@RestController
@RequestMapping("/erp/provider")
public class ProviderController {
    @Autowired
    private ProviderService providerService;
    //根据分页查询
    @PostMapping("/listProviderForPage")
    public R<Page<StockProvider>> findProvider(@RequestBody ProviderVo data) {
        return providerService.findProvider(data);
    }
    //添加供应商
    @PostMapping("/addProvider")
    public R addProvider(@RequestBody ProviderVo data) {
        return providerService.addProvider(data);
    }
    //修改回显信息
    @GetMapping("/getProviderById/{providerId}")
    public R getProviderById(@PathVariable Integer providerId) {
        return providerService.getProviderById(providerId);
    }
    //修改信息
    @PutMapping("/updateProvider")
    public R updateProvider(@RequestBody ProviderVo data) {
        return providerService.updateProvider(data);
    }
    //删除信息
    @DeleteMapping("/deleteProviderByIds/{providerIds}")
    public R deleteProviderByIds(@PathVariable List<Integer> providerIds) {
        return providerService.deleteProviderByProviderIds(providerIds);
    }
    //查询所有有效的生产厂家信息
    @GetMapping("/selectAllProvider")
    public R<List<StockProvider>> selectAllProvider() {
        return providerService.selectAllProvider();
    }
}
